package forecast.service;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import forecast.domain.Activity;
import forecast.domain.Forecast;


@Repository("hibernateForecastRepository")
@Transactional
public class HibernateForecastRepository implements ForecastRepository {
	
	private HibernateTemplate hibernateTemplate;
	
	 @Autowired
	 public void setSessionFactory(SessionFactory sessionFactory) {
	       hibernateTemplate = new HibernateTemplate(sessionFactory);
	 }

	public void saveForecast(Forecast forecast) {
		hibernateTemplate.saveOrUpdate(forecast);
		
	}

	public Forecast getForecast(long id) {
		return hibernateTemplate.get(Forecast.class, id);
	}

	public Set<Forecast> listForecasts() {
		return new HashSet<Forecast> (hibernateTemplate.find("from Forecast"));
	}

	public Set<Forecast> listForecasts(Date start, Date end) {
		// TODO Auto-generated method stub
		return null;
	}	
}